package com.ourteam.product.model.api;

import org.apache.commons.lang3.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.model.dao.ProductModelCodeTemplateDAOQueryBean;
import com.ourteam.product.model.domain.ProductModelCodeTemplateBean;

public class ProductModelCodeTemplateSearchModel extends AbstractSearchModel<ProductModelCodeTemplateDAOQueryBean> {

	private String templateName;
	
	private String targetType;
	
	private String inputObjectType;

	public String getTemplateName() {
		return templateName;
	}

	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}
	

	public String getTargetType() {
		return targetType;
	}

	public void setTargetType(String targetType) {
		this.targetType = targetType;
	}

	public String getInputObjectType() {
		return inputObjectType;
	}

	public void setInputObjectType(String inputObjectType) {
		this.inputObjectType = inputObjectType;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductModelCodeTemplateBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductModelCodeTemplateDAOQueryBean queryBean) throws Exception {

		ProductModelCodeTemplateDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNotBlank(templateName)) {
			criteria.andTemplateNameLike(templateName);
		}
		
		if (StringUtils.isNotBlank(targetType)) {
			criteria.andTargetTypeEqualTo(targetType);
		}
		
		if (StringUtils.isNotBlank(inputObjectType)) {
			criteria.andInputObjectTypeEqualTo(inputObjectType);
		}
		
	}

}
